<?php
namespace app\common\validate;

use think\Validate;

class UserValidate extends Validate
{
    protected $rule =   [
        'id'               => 'require|number',
        'page|页数'        => 'require|number',
        'limit|条数'       => 'require|number',
        'mobile|手机号'    => 'require|mobile',
        'code|验证码'      => 'require|length:4',
        'nickname|昵称'    => 'require|length:1,50',
        'avatar|昵称'      => 'require',
        'star|星级'        => 'require',
    ];
    
    protected $scene = [
        /** api */
        'mobile'   => ['mobile'],
        'login'    => ['mobile', 'code'],
        'register' => ['mobile', 'code', 'nickname', 'avatar'],

        /** admin */
        'show'     => ['id'],
        'list'     => ['page', 'limit'],
        'edit'     => ['id', 'nickname', 'star'],
    ];
}